<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>


<html:html xhtml="true" lang="true">
<head>
<title><bean:message key="welcome.title"/></title>
<html:base/>
<style type="text/css">
<!--
.style3 {
	font-size: 9px;
	color: #FF0000;
}
.style5 {color: #FF0000}
body {
	background-color: #FFFFFF;
}
-->
</style><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<script type="text/javascript">
function formatar()
{ 
	if(document.getElementById("cpf_cliente").id == "cpf_cliente")
	{
		limpacampos();
		if(document.getElementById("cpf_cliente").value.length == 14)
		{	
			var xx = document.getElementById("cpf_cliente").value;
			document.getElementById("cpf_cliente").value = xx;
		}
		else
		{
			var texto = document.getElementById("cpf_cliente").value;
			var tmp = texto.substring(0,3);
			tmp +=".";
			tmp +=texto.substring(3,6);
			tmp +=".";
			tmp += texto.substring(6,9);
			tmp += "-";
			tmp += texto.substring(9);
			document.getElementById("cpf_cliente").value = tmp;
			limpacampos();
		}
	}
	if(document.getElementById("cnpj_cliente").id == "cnpj_cliente")
	{
		limpacampos();
		if(document.getElementById("cnpj_cliente").value.length == 18)
		{	
			var xx = document.getElementById("cnpj_cliente").value;
			document.getElementById("cnpj_cliente").value = xx;
		}
		else
		{
			var texto = document.getElementById("cnpj_cliente").value;
			var tmp = texto.substring(0,2);
			tmp +=".";
			tmp += texto.substring(2,5);
			tmp +=".";
			tmp += texto.substring(5,8);
			tmp +="/";
			tmp += texto.substring(8,12);
			tmp +="-";
			tmp += texto.substring(12,15);
			document.getElementById("cnpj_cliente").value = tmp;
			limpacampos();
		}
	}
	
}
function limpacampos()
{	
	if(document.getElementById("cpf_cliente").value.length < 5)
		{	
			document.getElementById("cpf_cliente").value = "";
		}
		if(document.getElementById("cnpj_cliente").value.length < 6)
		{	
			document.getElementById("cnpj_cliente").value = "";
		}
	
}
</script>
<body>
<p>&nbsp;</p>
<html:errors/>
<html:form action="/CadastroCliente">
<table width="421" height="214" border="0" align="center" bordercolor="#FFFFFF" bgcolor="#FFFFFF">
  <tr>
    <td colspan="4"><div align="center"><strong>Cadastro de Cliente</strong></div></td>
  </tr>
  <tr>
    <td><span class="style3">* Campos Obrigatorios</span></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td><div align="left"><strong>Nome</strong><span class="style5">*</span></div></td>
    <td><div align="left">
      <html:text property="nome_cliente" disabled="false" maxlength="60" size="50" ></html:text>
    </div></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td><div align="left"><strong>E-Mail</strong><span class="style5">*</span></div></td>
      		<td><html:text property="email" disabled="false" maxlength="80" size="50"></html:text></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td><strong>Telefone <span class="style3">DD+99999999</span></strong></td>
    <td><html:text property="num_telefone" disabled="false" maxlength="10" size="10"></html:text></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td><strong>Celular <span class="style3">DD+99999999</span></strong><span class="style5">*</span></td>
    <td><html:text property="num_cel" disabled="false" maxlength="10" size="10"></html:text></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td><strong>Endere&ccedil;o</strong></td>
    <td><html:text property="rua_cliente" disabled="false" maxlength="80" size="50"></html:text></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td><strong>Complemento</strong></td>
    <td><html:text property="complemento_cliente" disabled="false" maxlength="100" size="50"></html:text></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td><div align="left"><strong>CNPJ
    </strong></div></td>
    <td>    
      <div align="left">
        <html:text property="cnpj_cliente" disabled="false" styleId="cnpj_cliente" maxlength="18" size="18" onchange="formatar()" ></html:text>
      </div></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td><strong>CPF</strong><span class="style5">*</span></td>
    <td><html:text property="cpf_cliente" disabled="false" styleId="cpf_cliente" maxlength="14" size="14" onchange="formatar()" ></html:text></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td><strong>Nome Fantasia </strong></td>
    <td><html:text property="nome_fantasia_cliente" disabled="false" maxlength="80" size="50"></html:text></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td><strong>Empresa</strong></td>
    <td><html:text property="site_cliente" disabled="false" maxlength="80" size="50"></html:text></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td><input type="submit" name="Submit" value="Cadastrar"></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>
</html:form>
</body>
</html:html>